#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<string.h>
int get_len(char s[], char t[]) {
	char temp[330];
	if (strlen(s) < strlen(t)) {			
		strcpy(temp, s); strcpy(s, t); strcpy(t, temp);
	}
	int m = strlen(s), n = strlen(t), i, j, min = 220;   	
	for (i = m + 2 * n - 1; i >= m + n; i--) s[i] = '0';	
	for (; i >= n; i--) s[i] = s[i - n];			
	for (; i >= 0; i--) s[i] = '0';						
	s[m + 2 * n] = '\0';
	for (i = 0, j = 0; i < m + 2 * n; i++, j++) {		
		if ((s[i] - '0') + (t[j] - '0') > 3) {		
			i = i - j; j = -1; continue;		
		}
		if (j == n) {			
			if (i <= 2 * n && n + m - (i - j) < min) min = n + m - (i - j); 
			else if (2 * n < i && i < n + m && m < min) min = m;				
			else if (i >= m + n && i - n < min) min = i - n;			
			continue;				
		}
	}
	return min;
}

int main() {
	char s[330], t[330];
	while ((scanf("%s", s)) != EOF) {
		scanf("%s", t);
		printf("%d\n", get_len(s, t));
	}
	return 0;
}
